# ====================================== #
#                                        #
#       YoghurtGum static library        #
#                                        #
# ====================================== #

include ../../YoghurtGum.mk

PROGS = $(YG_SDK)/YoghurtGum.a

all: $(PROGS)

rebuild: clean $(PROGS)

clean:
	@echo "###     Cleaning   ###"
	$(D)rm -f $(YG_INTERMEDIATE)

$(PROGS): $(YG_OBJECTS)
	@echo "###     Linking    ###"
	$(D)$(YG_ARCHIVER) \
	-vq \
	$(PROGS) \
	$(YG_NDK_PATH_LIB)/crtbegin_static.o \
	$(YG_NDK_PATH_LIB)/crtend_android.o \
	$^
	$(D)$(YG_ARCHIVER) \
	-vr \
	$(PROGS) \
	$(YG_NDK_PATH_LIB_ARM)/libstdc++.a \
	$(YG_NDK_PATH_LIB)/libc.a \
	$(YG_NDK_PATH_LIB)/libc.so \
	$(YG_NDK_PATH_LIB)/libm.a \
	$(YG_NDK_PATH_LIB)/libm.so \
	$(YG_NDK_PATH_LIB)/liblog.so \
	$(YG_NDK_PATH_LIB)/libGLESv1_CM.so \
	$(YG_NDK_PATH_LIB)/libGLESv2.so

$(YG_OBJECTS): $(YG_INT)/%.o : $(YG_SRC)/%.cpp
	@echo "###    Compiling   ###"
	$(D)$(YG_COMPILER) \
   -I$(YG_NDK_PATH_INC) \
   -I$(YG_HEADERS) \
   -I$(YG_LIBS) \
   -I$(YG_SRC) \
   -nostdlib \
   -fpic \
   -mthumb-interwork \
   -ffunction-sections \
   -funwind-tables \
   -fstack-protector \
   -fno-short-enums \
   -D__ARM_ARCH_5__ \
   -D__ARM_ARCH_5T__ \
   -D__ARM_ARCH_5E__ \
   -D__ARM_ARCH_5TE__ \
   -march=armv5te \
   -mtune=xscale \
   -msoft-float \
   -mthumb \
   -Os \
   -fomit-frame-pointer \
   -fno-strict-aliasing \
   -finline-limit=64 \
   -DANDROID \
   -DOS_ANDROID \
   -O2 \
   -DNDEBUG \
   -g \
   -Wall \
   -Werror \
   -w \
   -c \
   -MMD \
   -MP \
   -MF $@.tmp \
   $< \
   -o $@